package top.yuyufeng.mbuy.dto;

/**
 * @author yuyufeng
 * @date 2019/3/1.
 */
public class ResponseJson<T> {
    private boolean success;
    private T data;
    private String msg;

    public ResponseJson(boolean success, T data, String msg) {
        this.success = success;
        this.data = data;
        this.msg = msg;
    }

    public ResponseJson(boolean success, String msg) {
        this.success = success;
        this.msg = msg;
    }

    public ResponseJson(boolean success, T data) {
        this.success = success;
        this.data = data;
    }

    public static <T> ResponseJson success(T data, String msg) {
        return new ResponseJson<>(true, data, msg);
    }

    public static <T> ResponseJson<T> success(T data) {
        return new ResponseJson<>(true, data);
    }

    public static <T> ResponseJson<T> success() {
        return new ResponseJson(true,"成功");
    }

    public static ResponseJson fail(String msg) {
        return new ResponseJson(false, msg);
    }

    public ResponseJson() {
    }

    public boolean isSuccess() {
        return success;
    }

    public void setSuccess(boolean success) {
        this.success = success;
    }

    public T getData() {
        return data;
    }

    public void setData(T data) {
        this.data = data;
    }

    public String getMsg() {
        return msg;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }
}
